﻿#ifndef HANDLDATABASE_H
#define HANDLDATABASE_H

#include <QObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QJsonValue>
#include <QMap>
#include <QList>
#include <QSqlDatabase>
#include <QSqlQuery>

#include <QList>
#include <QPair>


class HandlDatabase : public QObject
{
    Q_OBJECT
public:
    explicit HandlDatabase(QObject *parent = nullptr);
    virtual ~HandlDatabase();

    void initDatabase();

    static HandlDatabase * gestance();

    //设置电机时间
    void setElectricalMach(int pins , int times);
    //设置管道时间
    void setPipeline(int pins , int times);

    //设置继电器时间
    void setRelays(int pins , int times);
    //设置泵时间
    void setPumps(int pins , int times);


    //得到电机时间
    int getElectricalMach(int pins );
    //得到管道时间
    int getPipeline(int pins );
    //得到继电器时间
    int getRelays(int pins );

    //得到泵时间
    int getPumps(int pins );

    //设置消息
    void setNumbersStautes(int numbers , int stautes);
    //得到消息状态
    int getNumbersStautes(int numbers );
signals:

public:
    static HandlDatabase  * m_handlDatabase;
    QSqlDatabase m_db;

    QMap<int , int> m_electricalMach;
    QMap<int , int> m_pipeline;
    QMap<int , int> m_relays;
    QMap<int , int> m_pumps;

    QList< QPair<int,int> > m_listInforDatas;
    int m_numberIndex;

};


#endif // HANDLDATABASE_H
